{include 'header.tpl'}
<style>
    #preview {
        position: absolute;
        border: 1px solid #ccc;
        background: #333;
        padding: 5px;
        display: none;
        color: #fff;
        width: 250px;
        height: 250px;
    }
    #preview img{
        width: 100%;
        height: 100%;
    }
</style>
<ol class="breadcrumb">
    <li><a href="/Shop/list">小红薯商城连锁店列表</a></li>
</ol>
<form method="get" action="/Shop/list" class="form-inline">
    <table>
        <tr>
            <td>
                <label for="form-w" class="control-label">连锁店名称：</label>
                <input class="form-control" id="name" name="name" value="{$smarty.get.name}" placeholder="" size="6"/>
            </td>

            <td>
                <label for="form-w" class="control-label">城市：</label>
                <input class="form-control" id="city" name="city" value="{$smarty.get.city}" placeholder="" size="6"/>
            </td>

            <td>
                <label for="form-w" class="control-label">联系电话：</label>
                <input class="form-control" id="phone" name="phone" value="{$smarty.get.phone}" placeholder="" size="10"/>
            </td>


            <td>
                <button type="submit" class="btn btn-primary">查找</button>
                <a href="/Shop/list" class="btn btn-danger">清空条件</a>
                <a href="/Shop/modify" class="btn btn-danger">添加连锁店</a>
                {*<button type="button" onclick="dao()" class="btn btn-primary">导出</button>*}
            </td>
        </tr>
    </table>
</form>
<div class="clearfix" style="height:30px;"></div>
<table class="table" style="table-layout: fixed;WORD-BREAK: break-all; WORD-WRAP: break-word">
    <tr>
        <td>ID</td>
        <td>连锁店</td>
        <td>门店图片</td>
        <td>店长</td>
        <td>专属二维码</td>
        <td>营业时间</td>
        <td>营业状态</td>
        <td>联系方式</td>
        <td>所在市</td>
        <td>起送金额</td>
        <td>地址</td>
        <td>属组</td>
        <td>经纬度</td>
        <td>状态</td>
        <td>操作</td>
    </tr>
    {foreach from=$data item=item}
        <tr>
            <td>{$item.id}</td>
            <td>{$item.name}</td>
            <td>
                {if $item.shop_img neq ""}
                    <img style="width: 80px;height: 80px;"  src="{$oss_url}{$item.shop_img}">
                {/if}
            </td>
            <td>{$item.manager}</td>
            <td>
                {if $item.ticket eq ''}
                <a class="create_qrcode" href="javascript:;" data-id="{$item.id}">点击生成二维码</a>
                {else}
                <a href="javascript:void(0)" class="preview"
                   rel='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket={$item.ticket}'>
                    <img src="https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket={$item.ticket}" style="width: 50px;height: 50px"/>
                    {/if}
            </td>
            <td>{$item.start_work_time}~{$item.stop_work_time}</td>
            <td>
                {if $item.work_status eq 1}营业中{/if}
                {if $item.work_status eq 2}已打烊{/if}
            </td>
            <td>{$item.phone}</td>
            <td>{$item.city}</td>
            <td>{$item.money}</td>
            <td>{$item.address}</td>
            <td>{$item.title}</td>
            <td>{$item.x},{$item.y}</td>
            <td>
                <span style="color: #4cae4c">{if $item.status eq 1}正常{/if}</span>
                <span style="color: #ff3b36">{if $item.status eq 2}禁用{/if}</span>
                <span style="color: #ff3b36">{if $item.status eq -1}删除{/if}</span>
            </td>
            <td>
                <a href="/Shop/modify?id={$item.id}" rel="">修改</a>
                <a onclick="return confirm('确定要删除此商铺？');" href="/Shop/del?id={$item.id}&status=-1"   >删除</a>
            </td>
        </tr>
    {/foreach}
</table>
{include "pager.tpl"}
<script type="text/javascript">
    $(function () {
        create_date_picker();
        imagePreview();
        $('.create_qrcode').click(function () {
            var self = $(this);
            $.get('/shop/qrcode',{ id:$(this).data('id')},function (result) {
                if(result.status == 1){
                    var $a = $("<a href='javascript:void(0)' class='preview' rel='"+result.qr_url+"'><a>");
                    $a.append('<img src="'+result.qr_url+'" style="width: 50px;height: 50px"/>');
                    imagePreview($a);
                    self.closest('td').html($a);
                }else{
                    layer.alert(result.msg);
                }
            });
        });
    });


    function dao(){
        var nickname = $('#nickname').val();
        var mobile = $('#mobile').val();
        var begin_date = $('#begin_date').val();
        var end_date = $('#end_date').val();
        var intentionE1=$("#intention option:selected");
        var intention = intentionE1.val();
//        alert(intention);
//        alert(nickname);
//        alert(mobile);
//        alert(end_date);

        location.href = "/admin/Order/excelDao?begin_date=" + begin_date + "&end_date=" + end_date+ "&nickname=" + nickname+ "&mobile=" + mobile + "&intention=" + intention;

    }

    this.imagePreview = function (obj) {
        /* CONFIG */

        xOffset = 10;
        yOffset = 30;

        // these 2 variable determine popup's distance from the cursor
        // you might want to adjust to get the right result
        /* END CONFIG */
        var obj = obj || 'a.preview';
        $(obj).hover(function (e) {
                this.t = this.title;
                this.title = "";
                var c = (this.t != "") ? "<br/>" + this.t : "";
                $("body").append("<div id='preview'><img src='" + this.rel + "' alt='Image preview' />" + c + "</div>");
                $("#preview")
                    .css("top", (e.pageY - xOffset) + "px")
                    .css("left", (e.pageX + yOffset) + "px")
                    .fadeIn("fast");
            },
            function () {
                this.title = this.t;
                $("#preview").remove();
            });
        $(obj).mousemove(function (e) {
            $("#preview")
                .css("top", (e.pageY - xOffset) + "px")
                .css("left", (e.pageX + yOffset) + "px");
        });
    };
</script>
{include 'footer.tpl'}